package com.ebt.m.customer.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.customer.view.CustomerItemActive;
import com.ebt.m.commons.buscomponent.listview.BaseListView;
import com.ebt.m.commons.buscomponent.listview.BasePresenter;
import com.ebt.m.commons.buscomponent.listview.ISectionFactory;
import com.ebt.m.commons.buscomponent.listview.IView;

/**
 *
 * @author Damon
 * @date 2017/11/02
 * 30天活动客户listview
 */

public class ListViewActivieThirty extends BaseListView<CustomerThirtyPresenter> {
    private int from;
    public ListViewActivieThirty(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public ListViewActivieThirty(Context context) {
        this(context, null);
    }

    public ListViewActivieThirty(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mRefreshLayout.setRefreshNeeded(true);
    }

    @Override
    protected ISectionFactory createViewFactory() {
        return new ISectionFactory() {
            @Override
            public IView createView(int viewType) {
                CustomerItemActive itemView = new CustomerItemActive(getContext());
                itemView.setFrom(from);
                return itemView;
            }
        };
    }


    @Override
    protected CustomerThirtyPresenter createPresenter() {
        return new CustomerThirtyPresenter(getContext(), this);
    }

    @Override
    public void loadNext() {

    }

    @Override
    public void update(Object... args) {
        super.update(args);
        from = (int) args[0];
        mPresenter.loadNew(args);

    }

    @Override
    protected boolean createFootView() {
        return false;
    }

    @Override
    protected View configEmptyView() {
        View emptyContent = LayoutInflater.from(getContext()).inflate(R.layout.common_list_empty_view, null);
        TextView textView = (TextView) emptyContent.findViewById(R.id.tv_empty);
        ImageView img = (ImageView) emptyContent.findViewById(R.id.iv_empty);
        textView.setText("暂无最近活动客户");
        img.setImageResource(R.drawable.ic_no_customer);
        return emptyContent;
    }

}
